package com.kingwang.training.ooad.coffeemaker.goodway;

/**
 * @author King
 */
public abstract class ContainmentVessel {
    private UserInterface ui;
    private HotWaterSource hotWaterSource;

    protected boolean brewing;
    protected boolean completed;

    public ContainmentVessel() {
        this.brewing = false;
        this.completed = true;
    }

    public void init(UserInterface ui, HotWaterSource hotWaterSource) {
        this.ui = ui;
        this.hotWaterSource = hotWaterSource;
    }

    public void start() {
        this.brewing = true;
        this.completed = false;
    }

    public void done() {
        this.brewing = false;
    }

    protected void declareComplete() {
        this.ui.complete();
        this.completed = true;
    }

    protected void containerAvailable() {
        this.hotWaterSource.resume();
    }

    protected void containerUnavailable() {
        this.hotWaterSource.pause();
    }

    public abstract Boolean isReady();
}
